<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <div id="app">
        <input type="button" value="修改" @click="changeS">
        <input type="text" v-focus:disabled.stop="s+'1'" >
    </div>

    
    <script src="./js/vue.js"></script>
    <script>

        Vue.directive("focus",{
            // bind:是在指令和dom元素初次绑定时，调用
            bind:function(el,binding){
                console.log("bind");
                console.log("el",el);
                console.log("binding",binding);
                /*
                binding:的内容：
                    arg: "disabled"
                    expression: "s+'1'"
                    modifiers: {stop: true}
                    name: "focus"
                    rawName: "v-focus:disabled.stop"
                    value: "hello1"
                */
            },
            // （指令所在的）dom元素插入到父节点（可以认为此时，dom元素已经渲染）时，调用
            inserted:function(el){
                console.log("inserted");
                console.log("el",el);
                el.focus();
            },
            // 当指令所绑定的数据发生变化时，调用
            update:function(){
                console.log("update");
            }
        });



        let vm = new Vue({
            el:"#app",
            data:{
               s:"hello"
            },
            methods:{
                changeS(){
                    this.s+="1";
                }
            }
        });


    </script>
</body>
</html>